//
//  OAMeCenterVC.m
//  OA项目
//
//  Created by innofive on 2018/4/12.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAMeCenterVC.h"
#import "OAMeCenterCell.h"
#import "OAAccountSecurityVC.h"
#import "OAMyInfoVC.h"

#import "OALawRuleVC.h"
#import "OAApproveOpinionVC.h"
#import "OAApproveRecordVC.h"

#import "OAResourcelistMangerVC.h"
@interface OAMeCenterVC ()

@end

@implementation OAMeCenterVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
   
    NSArray *arr  = @[
                     @[
                         @{@"image":@"1",
                           @"title":@"修改资料"
                           }
                         
                         ],
                     @[@{@"image":@"1",
                         @"title":@"账号安全"
                         },
                       @{@"image":@"1",
                         @"title":@"消息通知"
                         },
                       @{@"image":@"1",
                         @"title":@"关于我们"
                         }]
                     ];
    
    [self.dataArr addObjectsFromArray:arr];

    
    

    
}

-(void)onLoadViewByWillAppear:(UITableView *)view
{
    view.backgroundColor = hexCOLOR(@"F1F1F1");
    
    view.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    UIView *v = ({
        UIView *l = [UIView new];
//        l.backgroundColor = [UIColor redColor];
        l.frame = CGRectMake(0, 0,kScreenW,kFitH(225));
        l;
    });
    view.tableHeaderView = v;
    
    UIView *v1 = ({
        UIView *l = [UIView new];
        l.backgroundColor = [UIColor clearColor];
        l.frame = CGRectMake(0, 0,kScreenW,kFitH(125));
        l;
    });
    UIButton *button = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        l.frame = CGRectMake(kFitW(35),kFitH(70), kScreenW-kFitW(70),kFitH(40));
        l.cornerRadius = 3;
        l.masksToBounds = YES;
        [l setNormalTitle:@"退出登录"];
        [l AddTarget:self Action:@selector(onLoginOut:)];
        l.backgroundColor  = hexCOLOR(@"D4A451");
        l;
    });
    
     [v1 addV:button];
    
    
    view.tableFooterView = v1;
    
}
#pragma mark - 点击事件
-(void)onLoginOut:(UIButton *)btn
{
   
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSDictionary *dic = [self modelForIndexPath:indexPath];
   
    if (indexPath.section==0) {
        
        OAMyInfoVC *vc = [[OAMyInfoVC alloc]initWithStyle:(UITableViewStylePlain)];
        vc.title = @"个人资料";
        [self pushToVC:vc model:nil hideTabBar:YES];
    }
    else if (indexPath.row==2)
    {
        //OAApproveOpinionVC *vc = [[OAApproveOpinionVC alloc]initWithStyle:(UITableViewStylePlain)];
        //OALawRuleVC *vc = [[OALawRuleVC alloc]initWithStyle:(UITableViewStylePlain)];
        //OAApproveRecordVC *vc = [[OAApproveRecordVC alloc]initWithStyle:(UITableViewStylePlain)];
        OAResourcelistMangerVC *vc = [[OAResourcelistMangerVC alloc]initWithStyle:(UITableViewStylePlain)];
        
        //vc.title = @"审批意见";
//        vc.title = @"法律法规";
        //vc.title = @"审批记录";
        vc.title = @"资质及证书管理";
        [self pushToVC:vc model:nil hideTabBar:YES];
    }
    else
    {
        
        if (indexPath.row==0) {
            OAAccountSecurityVC *vc = [[OAAccountSecurityVC alloc]initWithStyle:(UITableViewStyleGrouped)];
            vc.title = dic[@"title"];
            [self pushToVC:vc model:nil hideTabBar:YES];
        }
    }
    
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return self.dataArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [self.dataArr[section] count];
}

-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    return [MCCellInfo configForCellId:cell Class:[OAMeCenterCell class] Height:kFitH(50) TableView:tableView];
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView HeaderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:header Class:[OAMeCenterheaderView class] Height:kFitH(10) TableView:tableView IsBian:NO];
}

-(id)modelForIndexPath:(NSIndexPath *)indexPath
{
    return self.dataArr[indexPath.section][indexPath.row];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
